﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

//////////////////////////////////////////////////////////////////////////
//Elective.cs                                                           //
//Last Edited: 20 Mar 2012                                              //
//                                                                      //
//Object that holds information necessary for electives                 //
//////////////////////////////////////////////////////////////////////////
public class Elective : Course
{
    protected int electiveID;
    protected String electiveName;
    protected Dictionary<String, Course> courses;
    protected String selectedCourseID;
    public Elective(int electiveID, String electiveName, String courseID, String dpt, String num, String name, Double credits, string term)
	{
        this.electiveID = electiveID;
        this.electiveName = electiveName;
        this.selectedCourseID = courseID;
        this.courseID = courseID;
        this.dpt = dpt;
        this.num = num;
        this.name = name;
        this.credits = credits;
        this.term = term;
        courses = new Dictionary<String, Course>();
	}
    public Elective(int electiveID, String electiveName, Course c)
    {
        this.electiveID = electiveID;
        this.electiveName = electiveName;
        this.selectedCourseID = c.getCourseID();
        this.courseID = c.getCourseID();
        this.dpt = c.getDpt();
        this.num = c.getNum();
        this.name = c.getName();
        this.credits = c.getCredits();
        this.term = c.getTerm();
        courses = new Dictionary<String, Course>();
    }
    public Elective copy()
    {
        Elective copy = new Elective(electiveID, electiveName, courseID, dpt, num, name, credits, term);
        Dictionary<String, Course> courseCopy = this.getCourses();
        foreach (Course c in courseCopy.Values)
        {
            copy.addCourse(c.copy());
        }
        return copy;
    }
    public Dictionary<String, Course> getCourses()
    {
        Dictionary<String, Course> courseCopy = new Dictionary<String, Course>();
        foreach (Course c in courses.Values)
        {
            courseCopy.Add(c.getCourseID(),c.copy());
        }
        return courseCopy;
    }
    public void addCourse(Course c)
    {
        if (c == null)
            return;
        courses.Add(c.getCourseID(), c);
    }
    public String getSelectedCourseID()
    {
        return selectedCourseID;
    }
    public void setSelectedCourseID(String courseID)
    {
        selectedCourseID = courseID;
        this.courseID = courseID;
    }
    public void changeTermOfCourses(String termCode)
    {
        this.term = termCode;
        foreach (Course c in courses.Values)
        {
            c.setTerm(termCode);
        }
    }
    public String getElectiveName()
    {
        return electiveName;
    }
    public int getElectiveID()
    {
        return electiveID;
    }
}